home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.cs.ubc.ca!bcsystems!sashome
- Newsgroups: comp.lang.c
- Subject: Suggestions welcome
- Message-ID: <1996Feb6.225454.7550@venus.gov.bc.ca>
- From: sasmith@bcsc02.gov.bc.ca (Steve Smith)
- Date: Wed, 07 Feb 96 06:56:34 GMT
- Organization: BC Systems Corporation
- Nntp-Posting-Host: vicsd211.dial.gov.bc.ca
- X-Newsreader: News Xpress 2.0 Beta #0
-
- I am writing a C++ Console application to extract information from a
- proprietary database file.
-
- In order to interpret some of the data in a record, I need to read in
- a flat file which contains lists of values for certain variables. A
- sample would be:
-
- ++$ CITYNAMES
- VICTORIA
- VANCOUVER
- EDMONTON
- CALGARY
- TORONTO
- MONTREAL
- QUEBEC
- ++$ END
-
- The city name field in the database record is a single byte, where 01 =
- VICTORIA, 02 = VANCOUVER etc.
-
- There are a number of such lists in the flat file, several have > 200 entries.
- I want to read these lists in to my program, and be able to access them
- using an array index (such as CityName[i]).
-
- I don't know how many elements will be in the array from one run to the
- next, so I can't (and wouldn't want to) statically allocate an array.
-
- The only way I can think of to accomplish this, is the read through the
- flat file twice.
-
- On the first pass, count the number of elements required for each
- unique list. Once I know how many elements are required I can dynamically
- allocate an array of pointers to string for each list.
-
- On the second pass through the file, I can allocate storage for each string,
- copy it into memory and initialize the char* array with the pointer.
-
- If anyone has any other suggestions on how I could accomplish this, I would be
- interested in hearing from them (either e-mail or post).
-
- Thanks in advance
-
- Steve Smith
- sasmith@orca.osg.gov.bc.ca
-
- them.
- each list
-